this._group.connect('destroy', Lang.bind(this, this._onGroupDestroy));
- this._actionKeys = {};
+ this._buttonKeys = {};
this._group.connect('key-release-event', Lang.bind(this, this._onKeyReleaseEvent));
this._backgroundBin = new St.Bin();
this._group.destroy();
},
- setActionKey: function(key, action) {
- this._actionKeys[key] = action;
- },
-
clearButtons: function() {
this.buttonLayout.destroy_all_children();
- this._actionKeys = {};
+ this._buttonKeys = {};
},
setButtons: function(buttons) {
else
x_alignment = St.Align.MIDDLE;
- let button = this.addButton(buttonInfo, { expand: true,
- x_fill: false,
- y_fill: false,
- x_align: x_alignment,
- y_align: St.Align.MIDDLE });
- buttonInfo.button = button;
+ this.addButton(buttonInfo, { expand: true,
+ x_fill: false,
+ y_fill: false,
+ x_align: x_alignment,
+ y_align: St.Align.MIDDLE });
}
},
let key = buttonInfo['key'];
let isDefault = buttonInfo['default'];
- if (isDefault && !key) {
- this._actionKeys[Clutter.KEY_KP_Enter] = action;
- this._actionKeys[Clutter.KEY_ISO_Enter] = action;
- key = Clutter.KEY_Return;
- }
+ let keys;
+
+ if (key)
+ keys = [key];
+ else if (isDefault)
+ keys = [Clutter.KEY_Return, Clutter.KEY_KP_Enter, Clutter.KEY_ISO_Enter];
+ else
+ keys = [];
let button = new St.Button({ style_class: 'modal-dialog-button',
reactive: true,
can_focus: true,
label: label });
-
button.connect('clicked', action);
+ buttonInfo['button'] = button;
+
if (isDefault)
button.add_style_pseudo_class('default');
if (!this._initialKeyFocusDestroyId)
this._initialKeyFocus = button;
- if (key)
- this._actionKeys[key] = action;
+ for (let i in keys)
+ this._buttonKeys[keys[i]] = buttonInfo;
this.buttonLayout.add(button, layoutInfo);
_onKeyReleaseEvent: function(object, event) {
let symbol = event.get_key_symbol();
- let action = this._actionKeys[symbol];
+ let buttonInfo = this._buttonKeys[symbol];
+
+ if (!buttonInfo)
+ return false;
+
+ let button = buttonInfo['button'];
+ let action = buttonInfo['action'];
- if (action) {
+ if (action && button.reactive) {
action();
return true;
}
this._promptEntry.clutter_text.set_password_char('\u25cf');
ShellEntry.addContextMenu(this._promptEntry, { isPassword: true });
this.setInitialKeyFocus(this._promptEntry);
- this._promptEntry.clutter_text.connect('activate', Lang.bind(this, this._doUnlock));
this._promptEntry.clutter_text.connect('text-changed', Lang.bind(this, function() {
this._updateOkButtonSensitivity(this._promptEntry.text.length > 0);
}));